////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
// All Rights Reserved.
// The following is Sample Code and is subject to all restrictions on such code
// as contained in the End User License Agreement accompanying this product.
// If you have received this file from a source other than Adobe,
// then your use, modification, or distribution of it requires
// the prior written permission of Adobe.
//
////////////////////////////////////////////////////////////////////////////////
package samples.photoviewer
{
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class Gallery
	{
		public var name:String;
		//public var nquery:String;
		//public var pquery:String;
		public var description:String;
		public var photos:ArrayCollection;
		public var pages:ArrayCollection;
		public var sizes:ArrayCollection;
		public var kinds:ArrayCollection;
		public var extensions:ArrayCollection;
		public var selected:int;

		private var photo:Photo;
		private var page:Page;
		private var size:Size;
		private var kind:Kind;
		private var extension:Extension;
		
		public function Gallery(gallery:Object=null)
		{
			photos = new ArrayCollection();
			pages = new ArrayCollection();
			sizes = new ArrayCollection();
			kinds = new ArrayCollection();
			extensions = new ArrayCollection();
			if (gallery != null)
			{
				fill(gallery);
			}
		}
		
		public function fill(gallery:Object):void
		{
			/*this.name = gallery.id;
			this.description = gallery.description;*/
			this.name = "";
			//this.nquery = gallery.nquery;
			//this.pquery = gallery.pquery;
			this.description = gallery.d;
			this.selected = 0;
			
			//for (var i:int=0; i < gallery.photo.length; i++)
			for (var i:int=0; i < gallery.doc.length; i++)
			{
				//photo = new Photo(gallery.photo[i]);
				photo = new Photo(gallery.doc[i]);
				photos.addItem(photo);
			}
			/*
			//added on 20090203 -- paging
			for (var j:int=0; j < gallery.page.length; j++)
			{
				page = new Page(gallery.page[j]);
				pages.addItem(page);
			}
			
			//added on 20090203 -- filter
			for (var k:int=0; k < gallery.size.length; k++)
			{
				size = new Size(gallery.size[k]);
				sizes.addItem(size);
			}
			for (var l:int=0; l < gallery.kind.length; l++)
			{
				kind = new Kind(gallery.kind[l]);
				kinds.addItem(kind);
			}
			for (var m:int=0; m < gallery.extension.length; m++)
			{
				extension = new Extension(gallery.extension[m]);
				extensions.addItem(extension);
			}
			*/
		}
	}
}